<template>
  <div class="q-header">
    <div class="q-header-nav-wrapper">
      <div class="q-header-log">
        <a href="">
          <img src="../assets/FgP-BkmxyKWjMKv-bAbvpXg4G2r2.png" alt="" />
        </a>
      </div>
      <div class="q-header-nav-menu">
        <ul>
          <li>目的地</li>
          <li>锦囊</li>
          <li>
            <el-dropdown>
              <span class="el-dropdown-link">
                社区<i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item icon="el-icon-camera">
                  旅行论坛<i class="el-icon-arrow-down el-icon--right"></i>
                </el-dropdown-item>
                <el-dropdown-item icon="el-icon-chat-line-square">
                  旅行问答
                </el-dropdown-item>
                <el-dropdown-item icon="el-icon-document"
                  >旅行分享生活平台</el-dropdown-item
                >
                <el-dropdown-item icon="el-icon-attract"
                  >特别策划</el-dropdown-item
                >
                <el-dropdown-item icon="el-icon-reading"
                  >旅行专栏</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </li>
          <li>行程助手</li>
          <li>
            <el-dropdown>
              <span class="el-dropdown-link">
                商城
                <i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item icon="el-icon-camera"
                  >旅行论坛</el-dropdown-item
                >
                <el-dropdown-item icon="el-icon-chat-line-square"
                  >旅行问答</el-dropdown-item
                >
                <el-dropdown-item icon="el-icon-document"
                  >旅行分享生活平台</el-dropdown-item
                >
                <el-dropdown-item icon="el-icon-attract"
                  >特别策划</el-dropdown-item
                >
                <el-dropdown-item icon="el-icon-reading"
                  >旅行专栏</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </li>
          <li>
            <el-dropdown>
              <span class="el-dropdown-link">
                民宿•酒店
                <i class="el-icon-arrow-down el-icon--right"></i>
              </span>
              <el-dropdown-menu slot="dropdown">
                <el-dropdown-item icon="el-icon-ship">机酒自由行</el-dropdown-item>
                <el-dropdown-item icon="el-icon-goods">当地玩乐</el-dropdown-item>
                <el-dropdown-item icon="el-icon-position"
                  >自由行</el-dropdown-item
                >
                <el-dropdown-item icon="el-icon-edit">保险</el-dropdown-item>
                <el-dropdown-item icon="el-icon-milk-tea"
                  >签证</el-dropdown-item
                >
                <el-dropdown-item icon="el-icon-notebook-2"
                  >私人订制</el-dropdown-item
                >
                <el-dropdown-item icon="el-icon-office-building"
                  >欧洲铁路</el-dropdown-item
                >
              </el-dropdown-menu>
            </el-dropdown>
          </li>
          <li>特价酒店</li>
        </ul>
      </div>
    </div>
    <div class="q-header-user">
      <div class="h-search">
        <form>
          <input type="text" v-model="searchForm.searchTxt" />
          <button><i class="el-icon-search"></i></button>
        </form>
        <span>|</span>
      </div>
      <div class="login-warp" v-show="sta">
        <a href=""><img src="../assets/QQ.png" /></a>
        <a href=""><img src="../assets/微信.png" /></a>
        <a href=""><img src="../assets/微博.png" /></a>
        <a @click="userLogin">登录</a>
        <a @click="userLogin">注册</a>
      </div>
      <div class="user-info" v-show="!sta">
        <ul>
          <li>Hi~ {{ userName }}</li>
          <li><span class="hover-span" @click="clearUserName">注销</span></li>
        </ul>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      /*homeMenu: [
        {
          menuTitle: "目的地",
          menuIcon: "",
        },
        {
          menuTitle: "锦囊",
          menuIcon: "",
        },
        {
          menuTitle: "社区",
          menuIcon: "el-icon-arrow-down el-icon--right",

        },
        {
          menuTitle: "行程助手",
          menuIcon: "",
        },
        {
          menuTitle: "商城",
          menuIcon: "el-icon-arrow-down el-icon--right",
        },
        {
          menuTitle: "民宿•酒店",
          menuIcon: "el-icon-arrow-down el-icon--right",
          menuChildren: [
            { label: '机酒自由行', icon: 'el-icon-ship' },
            { label: '当地玩乐', icon: 'el-icon-ship' },
            { label: '自由行', icon: 'el-icon-ship' },
            { label: '保险', icon: 'el-icon-ship' },
            { label: '签证', icon: 'el-icon-ship' },
            { label: '私人订制', icon: 'el-icon-ship' },
            { label: '欧洲铁路', icon: 'el-icon-ship' }
          ],
        },
        {
          menuTitle: "特价酒店",
          menuIcon: "",
        },
      ],*/
      sta: true,
      userName: window.sessionStorage.getItem("token"),
      searchForm: {
        searchTxt: "",
      },
    };
  },
  methods: {
    userLogin() {
      // for(var i = 0; i< this.homeMenu.length; i++){
      //   console.log(this.homeMenu[i].menuTitle);
      //   // for(var j = 0; j<this.homeMenu[i].menuChildren.length;j++){
      //   //   console.log(this.homeMenu[i].menuChildren[j].label);
      //   // }
      // }
      this.$router.push("/login");
    },
    clearUserName() {
      this.sta = true;
      this.$store.commit("clearUserInf");
    },
    loginState() {
      if (this.userName) {
        this.sta = false;
      } else {
        this.sta = true;
      }
    },
  },
  mounted() {
    this.loginState();
  },
  watch: {
    test() {
      this.act = 1;
      console.log(this.act);
    },
  },
};
</script>

<style scoped lang="less">
/deep/.el-icon--right {
  margin: 0;
}
.hover-span:hover {
  border-bottom: 2px solid white;
}
/deep/.el-dropdown-menu__item {
  font-size: 16px;
}
/deep/.el-dropdown-menu__item:focus,
.el-dropdown-menu__item:not(.is-disabled):hover {
  color: #3c3c3c;
  background-color: #e3fae1;
  border-left: none;
}

@media screen and (min-width: 320px){
  .q-header{
    width: 1220px;
  }
}
@media screen and (min-width: 1220px){
  .q-header{
    width: 100%;
  }
}
.q-header {
  height: 60px;
  margin: 0 auto;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.3) 10%, transparent);
  max-width: 1920px;
  .q-header-nav-wrapper {
    float: left;
    padding-left: 30px;
    width: auto;
    height: 60px;

    .q-header-log {
      padding-top: 14px;
      width: 76px;
      height: 36px;
      float: left;

      img {
        height: 100%;
      }
    }

    .q-header-nav-menu {
      float: left;
      margin-left: 18px;
      font-size: 16px;

      ul {
        padding: 0;
        margin: 0;
      }

      li {
        float: left;
        padding: 15px 10px;
        color: white;
        font-weight: 700;
        border-top: transparent solid 5px;
      }

      li:hover {
        border-top: 5px solid #fff;
        transition: border-top 0.5s;
      }

      .el-dropdown-link {
        color: white;
        font-size: 16px;
      }
    }
  }

  .q-header-user {
    float: right;
    padding-right: 30px;
    height: 60px;
    color: white;
    font-size: 14px;
    line-height: 60px;
    .h-search {
      float: left;
      position: relative;
      form {
        float: left;
      }
      input {
        float: right;
        margin-top: 18px;
        outline: none;
        width: 188px;
        height: 25px;
        text-indent: 5px;
        border: none;
        border-radius: 2px;
        background-color: white;
        transition: all 0.5s;
      }
      button {
        width: 25px;
        height: 25px;
        border: none;
        outline: none;
        position: absolute;
        top: 17px;
        right: 25px;
        color: springgreen;
        font-weight: 700;
        font-size: 18px;
        padding-top: 3px;
        background-color: transparent;
      }
      span {
        float: left;
        padding: 0 10px;
      }
    }
    .login-warp {
      float: left;
      font-size: 16px;
      a {
        padding: 0 8px;
        color: white;
        font-weight: 700;
      }
    }
    .user-info {
      float: left;
      font-size: 18px;
      li {
        float: left;
        padding: 0 8px;
      }
    }
    img {
      vertical-align: middle;
      width: 20px;
      height: 20px;
    }
  }
}
</style>